﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace LianXi1013.Repostory
{
    public interface IBaseRepostory<TEntity>
        where TEntity : class
    {
        /// <summary>
        /// 根据主键单删
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int Delete(int id);
        /// <summary>
        /// 按实体删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        int Delete(TEntity entity);
        /// <summary>
        /// 根据数组批量删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        int Delete(int[] idList);
        /// <summary>
        /// 实体集批量删除
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        int Delete(List<TEntity> entity);
        /// <summary>
        /// 按条件删除
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        int Delete(Expression<Func<TEntity, bool>> condition);
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        TEntity Insert(TEntity entity);
        /// <summary>
        /// Queryable查询
        /// </summary>
        /// <returns></returns>
        IQueryable<TEntity> Queryable();
        /// <summary>
        /// 查询第一个
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        TEntity FirstQueryable(int id);
        /// <summary>
        /// 查询全部
        /// </summary>
        /// <returns></returns>
        List<TEntity> EntoityAll();
        /// <summary>
        /// 根据条件进行查询
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        List<TEntity> Query(Expression<Func<TEntity, bool>> condition);
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        int PutEntity(TEntity entity);
    }
}
